package com.pccw.service.iter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.caucho.services.server.ServiceContext;
import com.pccw.service.exception.InteractionException;

public class loginInterceptor implements MethodInterceptor {

	public Object invoke(MethodInvocation invocation) throws Throwable {
		HttpServletRequest request=(HttpServletRequest) ServiceContext.getContextRequest();
		HttpSession session=request.getSession();
		if(session.getAttribute("user")==null){
			System.out.println("没有登录，拦截");
			session.setAttribute("user", "guest");
			InteractionException i=new InteractionException("没有登录",99999);
			throw i;
		}else{
			return invocation.proceed();
		}
	}
}